package com.example.weather.utils;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpUtil {
    private static HttpURLConnection connection;

    public static HttpURLConnection getConnection(String strUrl) {
        try {
            URL url = new URL(strUrl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setConnectTimeout(15000);
            connection.setReadTimeout(15000);
            connection.setRequestProperty("Connection", "Keep_Alive");
            connection.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 " +
                    "(KHTML, like Gecko) Chrome/51.0.2704.7 Safari/537.36");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return connection;
    }
}
